package com.underconverbg.livedemo;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;

/**
 * Created by Administrator on 2016/7/5.
 */
public class AlertDialogFragment extends DialogFragment
{
    public interface DialogFragmentClickImpl
    {
        void doPositiveClick();
        void doNegativeClick();
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState)
    {
        Log.e("TAG", "onCreateDialog");
        return new AlertDialog.Builder(getActivity())
//                .setIcon(R.drawable.ic_launcher)
                .setTitle("直播")
                .setMessage("是否退出直播")
                .setPositiveButton(android.R.string.ok,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                DialogFragmentClickImpl impl = (DialogFragmentClickImpl) getActivity();
                                impl.doPositiveClick();
                            }
                        }
                )
                .setNegativeButton(android.R.string.cancel,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                DialogFragmentClickImpl impl = (DialogFragmentClickImpl) getActivity();
                                impl.doNegativeClick();
                            }
                        }
                )
                .create();
    }
}
